<template>
	<view>
		<view class="team_box">
			<view class="team_tit">
				<text>本月新增代理(人)</text>
				<h2>{{news.month_total}}</h2>
				<view class="tit">
					<view class="">
						<h5>{{news.all_total}}</h5>
						<text>累计(人)</text>
					</view>
					<view class="">
						<h5>{{news.prev_month_total}}</h5>
						<text>上月新增(人)</text>
					</view>
				</view>
			</view>
			<view class="team_list" v-for="(item,index) in data" :key="index" v-if="total > 0">
				<view class="team_list_left">
					<u-avatar :src="item.avatar" default-url="../../../static/default.jpg" size="55" shape="square"></u-avatar>
				</view>
				<view class="team_list_right">
					<view class="team_list_tit">
						<view>
							<text style="font-weight: bold;">{{item.name}}</text>
							<text style="margin-left: 16rpx; color: #82848a;" @click="phoneClick(item.phone)">{{item.phone}}</text>
							<text v-if="item.platform==1" class="platform_tags blues">传统</text>
							<text v-else class="platform_tags reds">传统 + 积分</text>
						</view>
						<u-icon size="20" name="phone" @click="phoneClick(item.phone)"></u-icon>
					</view>
					<view class="list">
						<view>
							<view>
								<u-icon size="18" name="../../../static/teams.png"></u-icon>
							</view>
							<u--text size="12" bold :text="item.team_nums"></u--text>
						</view>
						<view>
							<view>
								<u-icon size="13" name="clock"></u-icon>
							</view>
							<u--text size="12" :text="item.create_time"></u--text>
						</view>
					</view>
				</view>
			</view>
			<u-empty v-else mode="list" icon="/static/Empty/data_null.png">
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				news: {},
				data: [],
				bottom: true,
				page: 1,
				total: 0,
				product_id: null,
				type: 1
			}
		},
		onLoad(e) {
			this.product_id = e.product_id
			this.type = e.type
			this._news()
			this._list()
		},
		//下拉刷新
		onReachBottom() {
			if (this.bottom == true) {
				this.page += 1
				this._list()
			}
		},
		methods: {
			// 团队信息
			async _news() {
				const {
					data: res
				} = await this.$myHttp({
					url: 'Datas/getProductTeamDetailCount',
					data: {
						type: this.type
					}
				});
				if (res.code == 200) {
					this.news = res.data
				}
			},
			// 团队列表
			async _list() {
				uni.showLoading({
					title: '加载中'
				});
				const {
					data: res
				} = await this.$myHttp({
					url: 'Datas/getProductTeamDetail',
					data: {
						product_id: this.product_id,
						page: this.page,
						page_size: 15
					}
				});
				if (res.code == 200) {
					if (res.data !== undefined && res.data !== null && res.data.length >
						0) {
						if (this.page == 1) {
							this.total = res.data.length
							this.data = res.data
							uni.hideLoading()
						} else {
							this.data = [...this.data, ...res.data]
							uni.hideLoading()
						}
					} else {
						uni.hideLoading()
						this.bottom = false
					}
				} else {
					uni.showToast({
						title: res.msg,
						duration: 1000,
						icon: "none"
					});
					this.bottom = false
				}
			},
			info() {
				uni.navigateTo({
					url: '/pages/data/team/team_info'
				})
			},
			phoneClick(tel) {
				uni.makePhoneCall({
					phoneNumber: tel
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.team_box {
		padding-bottom: 20rpx;
		.team_tit {
			padding: 50rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			background: url(/static/team_bg.jpg) no-repeat center;

			text {
				font-size: 28rpx;
				color: #dbe6ff;
			}

			h2 {
				font-size: 52rpx;
				font-weight: 500;
				margin: 30rpx 0;
				color: #fff;
			}

			.tit {
				display: flex;
				justify-content: space-between;
				align-items: center;
				width:85%;
				margin-top: 30rpx;
			
			}

			h5 {
				color: #fff;
				font-size: 32rpx;
				text-align: center;
				margin-bottom: 10rpx;
				
			}
		}

		.team_list {
			padding: 30rpx;
			margin: 30rpx;
			border-radius: 10rpx;
			display: flex;
			box-shadow: 7px 0px 30px -18px #888888;
			background-color: #ffffff;
			
			.team_list_left {
				width: 20%;
				align-items: center;
			}
			
			.team_list_right {
				width: 80%;
				.team_list_tit {
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding-bottom: 12rpx;
					border-bottom: #eee solid 1px;
				
					text {
						font-size: 28rpx;
					}
					
					.platform_tags {
						margin-left: 10rpx;
						padding: 2rpx 8rpx;
						border-radius: 10rpx;
						color: #ffffff;
						font-size: 24rpx;
					}
					
					.blues {
						background-color: #2979ff;
					}
					
					.reds {
						background-color: #fa3534;
					}
				}
				
				.list {
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding-top: 10rpx;
					
					view {
						display: flex;
						
						view {
							margin-right: 5rpx; padding-top: 5rpx;
						}
					}

					text {
						font-size: 28rpx;
					}
				}
			}
		}
	}
</style>
